<template>
  <div class="grand-child">
    <h3>孙组件</h3>
    <h4>银子:{{ money }}万元</h4>
    <h4>车子:一辆{{ y.brand }},价值{{ y.price }}亿元</h4>
    <button @click="updateMoney(6)">花爷爷的钱</button>
  </div>
</template>

<script setup lang="ts">
import { inject } from "vue";
let { money, updateMoney } = inject("moneyContext", {
  money: 0,
  updateMoney: (x: number) => {},
});
let y = inject("car", { brand: "未知", price: 0 });
</script>

<style scoped>
.grand-child {
  background: rgb(141, 147, 240);
  padding: 10px;
  box-shadow: 0 0 10px black;
  border-radius: 10px;
}
</style>
